package com.framework.common.dto;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotNull;
import java.io.Serializable;

@Data
@Accessors(chain = true)
@JsonIgnoreProperties(ignoreUnknown = true)
public class PageDTO implements Serializable {

    private Long corpId;

    /**
     * 当前页
     */
    @ApiModelProperty("当前页")
    @NotNull(message = "当前页不能为空")
    private Integer current = 1;

    /**
     * 每页大小
     */
    @ApiModelProperty("每页大小")
    @NotNull(message = "每页大小不能为空")
    private Integer pageSize = 15;

    @ApiModelProperty("关键字搜索")
    private String searchText;

    @ApiModelProperty("搜索起始时间")
    private String startTime;

    @ApiModelProperty("搜索终止时间")
    private String endTime;

    @ApiModelProperty("排序字段")
    private String sortField;

    @ApiModelProperty("排序顺序 升序:asc 降序 desc")
    private String sortOrder;

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize == 0 ? 15 : pageSize;
    }
}
